package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface CategoryMapper {
    /**修改分类 */
    void updateCategory(Category category);
    /**分页查找类*/
    Page<Category> selectCategory(String name, Integer type);

    /**分类的状态开启/禁用*/
    void categoryStatus(Integer status, Long id, Long updateUser, LocalDateTime updateTime);

    /**增新分类*/
    void insertCategory(Category category);
/**删除分类*/
    @Delete("delete from category where id = #{id}")
    void deleteCategory(Integer id);
/**根据类型查询分类*/
//        @Select("select * from category where type = #{type}")
        @Select("select * from category where type = #{type}")
        List<Category> selectByType(Integer type);

/**查询dish表中是否有该分类关联的菜品*/
@Select("select id from dish where category_id = #{categoryId}")
    List<Integer> selectDishId(Integer categoryId);

    /**查询dish表中是否有该分类关联的套餐*/
    @Select("select id from setmeal where category_id = #{categoryId}")
    List<Integer> selectSetmealId(Integer categoryId);

    @Select("select * from category")
    List<Category> selectAll();
}
